var grid02 = $('#jgTable02'),
    grid03 = $('#jgTable03');

var Data02 = [],
    Data03 = [];

for(var i=0;i<10;i++){
    Data02.push({});
    Data03.push({});
}

// 日历
$('.form_datetime').datetimepicker({
    //minView: "month", //选择日期后，不会再跳转去选择时分秒 
    language:  'zh-CN',
    format: 'yyyy-mm-dd hh:ii:ss',
    todayBtn:  1,
    autoclose: 1,
});

$(function(){
    gridInit02();
    gridInit03();
    $("li[data-opt='back']").on('click', back);  
});

function alarmFormatter(cellvalue, options, rowdata){
    var grid = $(this);
    if(JSON.stringify(rowdata) !== '{}'){
        cellvalue = '<a href="javascript:0" opt-data="'+grid[0].id+'_delete" title="删除"><i class="fa fa-trash-o"></i></a>';
    }else{
        cellvalue = '';
    }
    return cellvalue;
}
function gridInit02(){
    var gridData02 = Object.create(gridData);
    gridData02.grid = $('#jgTable02');
    gridData02.datatype = "local";
    gridData02.rowNum = '100';
    gridData02.colModel = [
        {label:'基于类型', name:''},
        {label:'基于单号', name:''},
        {label:'基于行号', name:''},
        {label:'父物料代码', name:''},
        {label:'父物料描述', name:''},
        {label:'库存处理', name:''},
        {label:'物料代码', name:''},
        {label:'物料描述', name:''},
        {label:'商品规格', name:''},
        {label:'收款类别', name:''},
        {label:'基于数量', name:''},
        {label:'数量', name:''},
        {label:'单位', name:''},
        {label:'销售价', name:''},
        {label:'总金额', name:''},
        {label:'备注', name:''},
        {label:'状态', name:''},
        {label:'出库数量', name:''},
        {label:'未出库数量', name:''},
        {label:'客户签收数量', name:''},
        {label:'客户未签收数量', name:''},
        {label:'操作', name:'Options', width:110, formatter:alarmFormatter, sortable:false}
    ];
    gridData02.scroll = true;
    gridData02.height = '390px';
    gridData02.beforeRequest = function(){
        gridData02.grid.jqGrid("setGridParam", {
            data : Data02,
        });
    };
    gridData02.loadComplete = function(xhr){
        gridSize();
    };
    gridInit(gridData02);
}

function gridInit03(){
    var gridData03 = Object.create(gridData);
    gridData03.grid = $('#jgTable03');
    gridData03.datatype = "local";
    gridData03.rowNum = '100';
    gridData03.colModel = [
        {label:'应收账款类型', name:''},
        {label:'收款类别', name:''},
        {label:'发货通知应收款金额', name:''},
        {label:'发货通知冲抵预收金额', name:''},
        {label:'发货通知后应支付金额', name:''},
        {label:'拣货差异金额', name:''},
        {label:'拣货差异抵充预收金额', name:''},
        {label:'签收差异金额', name:''},
        {label:'签收差异冲抵预收金额', name:''},
        {label:'发货后应支付金额', name:''},
        {label:'已收款金额', name:''},
        {label:'未收款金额', name:''},
        {label:'收款状态', name:''},
        {label:'操作', name:'Options', width:110, formatter:alarmFormatter, sortable:false}
    ];
    gridData03.scroll = true;
    gridData03.height = '390px';
    gridData03.beforeRequest = function(){
        gridData03.grid.jqGrid("setGridParam", {
            data : Data03,
        });
    };
    gridData03.loadComplete = function(xhr){
        gridSize();
    };
    gridInit(gridData03);
}

//Options
function back(){
    window.open('OMS000202.html', '_self');
}

//样式
function gridSize(){
    grid02.setGridWidth($('.u_tabs_container').width() - 30);
    grid03.setGridWidth($('.u_tabs_container').width() - 30);
}